#ifndef _LIST_H_
#define _LIST_H_

typedef struct s_list
{
    struct s_list *prev;
    struct s_list *next;
} list_t;

/* 链表初始化 */
void list_init(list_t *list);
void __list_add(list_t * node, list_t * prev, list_t * next);
void __list_del(list_t * prev, list_t * next);
void list_add(list_t * node, list_t * head);
void list_add_tail(list_t * node, list_t * head);
void list_del(list_t * entry);

/* list_entry - 访问一个节点 */
#define list_entry(ptr, type, member) \
        ((type *) ((char *) (ptr) - (unsigned long) (&((type *) 0)->member)))

/* list_for_each - 遍历一个链表 */
#define list_for_each(pos, head) \
        for (pos = (head)->next; pos != (head); pos = (pos)->next)

#endif
